//simSpace
//{	minx: 0,
//	miny: 0,
//	maxx: 10,
//	maxy: 10
//}
//screenSpace
//{	minx:5,
//	miny:5,
//	maxx:500,
//	maxy:500
//}

function UnitsConverter(simSpace, screenSpace){
	this.xFactor = (screenSpace.maxx - screenSpace.minx + 0.0) / (simSpace.maxx - simSpace.minx + 0.0);
	this.xOffset = screenSpace.minx-simSpace.minx;
	this.yFactor = (screenSpace.maxy - screenSpace.miny + 0.0) / (simSpace.maxy - simSpace.miny + 0.0);
	this.yOffset =  -simSpace.miny;
	
	this.convert = function(simCoords){
		retVal = 
		{
				x : Math.round(this.xOffset + simCoords.x * this.xFactor),
				y : Math.round(screenSpace.maxy - (this.yOffset + simCoords.y * this.yFactor))
		};
		return retVal;
	};
}